#!/bin/zsh

clear

work_dir=$PWD
echo "正在编译用户程序 ..."

if [ ! -f "umake.sh" ]; then
	echo "当前目录与该脚本不在同一层"
	exit 1
fi

if [ ! -d "build" ]; then
	echo "创建 build 目录"
	mkdir $work_dir/build
	if [ ! $? -eq 0 ]; then
		echo "创建 build 目录失败"
		exit 1
	fi
else
	rm -rf build/*
fi

echo "进入build目录"
cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=YES ..
make -j2
cd $work_dir

